<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>

<div class="sf_admin_form">
  <?php echo form_tag_for($form, '@egresos',array('id'=>'egresos')) ?>
    <?php echo $form->renderHiddenFields() ?>

    <?php if ($form->hasGlobalErrors()): ?>
      <?php echo $form->renderGlobalErrors() ?>
    <?php endif; ?>

    <?php foreach ($configuration->getFormFields($form, $form->isNew() ? 'new' : 'edit') as $fieldset => $fields): ?>
      <?php include_partial('egresos/form_fieldset', array('egresos' => $egresos, 'form' => $form, 'fields' => $fields, 'fieldset' => $fieldset)) ?>
    <?php endforeach; ?>

    <?php include_partial('egresos/form_actions', array('egresos' => $egresos, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?>
  </form>
</div>
<script type="text/javascript">
jQuery(function() {

var importe =         jQuery("#egresos_importe"),
                      allFields = jQuery([]).add(importe),
                      tips = jQuery(".validateTips");

                      function updateTips(t) {
			tips
				.text(t)
				.addClass('ui-state-highlight');
			setTimeout(function() {
				tips.removeClass('ui-state-highlight', 1500);
			}, 500);
		}


function checkPositivos(o,n){
                    if(o.val() < 0){
                        o.addClass('ui-state-error');
			updateTips(n + " debe ser positivo.");
			return false;
                    }
                    else{return true}

                }

function validar(){

                   var bValid = true;
	           allFields.removeClass('ui-state-error');
                   bValid = bValid && checkPositivos(importe,"El importe");


                    return bValid;
                }


jQuery("#egresos").submit(function(){

                    return validar();
                 });

                 });
	</script>